package com.bqtt.tumor.demo.business;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.bqtt.tumor.demo.common.MyBeanFactory;
import com.bqtt.tumor.demo.data_access.TreatmentTrackHistoryDAO;
import com.bqtt.tumor.demo.entity.Feature;
import com.bqtt.tumor.demo.entity.TreatmentTrackHistory;

public class TreatmentTrackHistoryService {

	
	private static TreatmentTrackHistoryDAO treatmentTrackHistoryDAO = (TreatmentTrackHistoryDAO) MyBeanFactory.getBean("treatmentTrackHistoryDAO");
	private static Logger log = LoggerFactory.getLogger(TreatmentTrackHistoryService.class);
	
	public static List<TreatmentTrackHistory> searchByCondition(TreatmentTrackHistory condition,int pageSize,int pageNo)
	{
		
		List<TreatmentTrackHistory> result = treatmentTrackHistoryDAO.fuzzyFindByProperties(condition.getSQLValidAttributes(),pageSize,pageNo);

		return result;
	}
	
	public static List<TreatmentTrackHistory> searchByCondition(TreatmentTrackHistory condition,int pageSize,int pageNo,long id)
	{
		
		List<TreatmentTrackHistory> result = treatmentTrackHistoryDAO.fuzzyFindByProperties(condition.getSQLValidAttributes(),pageSize,pageNo);
		
		for(TreatmentTrackHistory item:result)
		{
			if(item.getTreatment_track_history_id()==id)
			{
				item.setDisplayName("inline-block");
			}
			item.fillStringField();
		}
		return result;
	}
	
	public static boolean add(TreatmentTrackHistory obj)
	{
		try
		{
			treatmentTrackHistoryDAO.save(obj);
			return true;
		}
		catch(Exception e)
		{
			log.error(e.getMessage());
	     	return false;	
		}
		
	}
	
	public static boolean update(TreatmentTrackHistory obj)
	{
		try
		{
			 
			if(obj.getTreatment_track_history_id()>0)
			{
				treatmentTrackHistoryDAO.update(obj);
				return true;
			}
			else
				
			return false;
		}
		catch(Exception e)
		{
			log.error(e.getMessage());
	     	return false;	
		}
		
	}
}
